package com.isoft.farm.common.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class SysTimeAspect {
    @Pointcut("bean(sysUserServiceImpl)")
    public void doTime(){}

    @Before("doTime()")
    public void DoBefore(JoinPoint jp){
        System.out.println("time:DoBefore");
    }
    @After("doTime()")
    public void DoAfter(JoinPoint jp){
        System.out.println("time:DoAfter");
    }
    @AfterReturning("doTime()")
    public void DoAfterReturning(JoinPoint jp){
        System.out.println("time:DoAfterReturning");
    }
    @AfterThrowing("doTime()")
    public void DoAfterThrowing(JoinPoint jp){
        System.out.println("time:DoAfterThrowing");
    }
    @Around("doTime()")
    public Object DoAround(ProceedingJoinPoint jp) throws Throwable{
        try {
            System.out.println("time:DoAround(),before");
            Object o=jp.proceed();
            System.out.println("time:DoAround(),after");
            return o;
        }catch (Throwable e){
            System.out.println(e.getMessage());
            throw e;
        }
    }

}
